home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
mystic.zip
/
PAS5.DOC
< prev
next >
Wrap
Text File
|
1986-02-27
|
23KB
|
1,712 lines
Mystic Pascal User Manual 29
8. Procedures and Functions
This section of the manual describes procedures and
functions. Procedures and functions which are used in
Input/Output processing are described in section 9. Multi-
tasking procedures are described in section 7.
Procedure Purpose
--------- -------
DISPOSE deallocate dynamic variable
+ INTR interrupt call
NEW allocate dynamic variable
PACK unimplemented
UNPACK unimplemented
Function Return Value
-------- ------------
ABS absolute value
ARCTAN arctangent
CHR convert integer to character
COS cosine
EXP exponential function
+ FLOAT convert integer to real
+ FRACTION fractional part of real
+1.6 INTSTR convert integer to string
LN natural logarithm
ODD test for odd integer
+ OFFSET offset of a variable
ORD convert ordinal to integer
PRED preceding ordinal
+1.6 REALSTR convert real number to string
ROUND convert real number to integer
+ SEGMENT segment of a variable
SIN sine
SQR square
SQRT square root
+1.6 STRINT convert string to integer
+1.6 STRREAL convert string to real number
SUCC succeeding ordinal
TRUNC convert real number to integer
+1.6 UPCASE convert char to upper case
Section 8: Procedures and Functions
Mystic Pascal User Manual 30
8.1 ABS
ABS( expression )
The ABS standard function returns the absolute value of an
integer or real expression. The result is of the same type as
the input expression.
Examples:
A := ABS( X );
WRITELN( 'ABSOLUTE VALUE IS',ABS( COS( Y )));
B := ABS( X + Y / Z );
Section 8: Procedures and Functions
Mystic Pascal User Manual 31
8.2 ARCTAN
ARCTAN( expression )
This standard function returns the arctangent of a real or
integer expression. The result type is real and is expressed in
radians.
Examples:
WRITELN( ARCTAN( A + 3.14159 ));
NODE.VALUE := OLDNODE.VALUE + ARCTAN( V );
Section 8: Procedures and Functions
Mystic Pascal User Manual 32
8.3 CHR
CHR( integer_expression )
The CHR standard function converts an integer expression
into a character. The result type is char. If the integer
expression is less than zero or greater than 255, a run-time
error occurs.
CHR is often used for sending control characters to output
devices.
Examples:
WRITE( CHR( 12 ));
TAB := CHR( 9 );
CARRIAGERETURN := CHR(13);
LINEFEED := CHR(10);
Section 8: Procedures and Functions
Mystic Pascal User Manual 33
8.4 COS
COS( expression )
The COS standard function returns the cosine of a real or
integer expression whose value is given in radians. The result
type is real.
Examples:
WRITELN( COS( ANGLE ));
NODE.COSINE := COS( N );
WRITELN( COS( VELOCITY / CHARGE ));
Section 8: Procedures and Functions
Mystic Pascal User Manual 34
8.5 DISPOSE
DISPOSE( pointer_variable )
The DISPOSE procedure is used to deallocate dynamic
variables. The pointer_variable addresses a dynamic variable in
dynamic storage. After execution of the procedure the space
released is available for other uses.
Mystic Pascal supports true dynamic storage with auto-
compression. When blocks are freed up, storage fragmentation
occurs -- unused blocks tend to accumulate. Because many blocks
tend to be small, they cannot be immediately reused for another
purpose. When storage becomes short an auto-compression is
initiated by the Pascal system.
Example:
PROCEDURE DISPOSEDEMO;
TYPE
DYNVAR = ARRAY [1..200] OF CHAR;
VAR
POINTER : ^DYNVAR;
BEGIN
NEW( POINTER ); (* ALLOCATE A DYNAMIC VAR *)
(* DO SOME PROCESSING WITH THE DYNAMIC VAR *)
DISPOSE( POINTER ); (* FREE UP THE 200 BYTES *)
END;
Section 8: Procedures and Functions
Mystic Pascal User Manual 35
8.6 EXP
EXP( expression )
The exponential function computes e to the x power, where x is a
real or integer expression. The result type is real.
Examples:
X := EXP( Y );
SHIPVELOCITY := EXP( WARPFACTOR );
Section 8: Procedures and Functions
Mystic Pascal User Manual 36
8.7 FLOAT (Non-Standard Feature)
FLOAT( integer_expression )
The Float function converts integers to real numbers. The
result type is real.
Section 8: Procedures and Functions
Mystic Pascal User Manual 37
8.8 FRACTION (Non-Standard Feature)
FRACTION( real_expression )
The Fraction function returns the fractional part of a real
number. The result type is real.
Section 8: Procedures and Functions
Mystic Pascal User Manual 38
8.9 INTR (Non-Standard Feature)
INTR( interrupt, registers )
The INTR procedure permits access to DOS and BIOS functions
by directly calling interrupt routines. The standard DOS
interrupt is number 33. The interrupt number must be an integer
expression. The registers variable is used to set the 8086
registers on entry and they are stored into the variable on
return from the interrupt routine.
Registers is declared as:
REGISTERS = RECORD